package com.lock;

import org.openjdk.jol.info.ClassLayout;

/**
 * @author: csh
 * @Date: 2021/5/11 14:38
 * @Description:轻量级锁状态
 */
public class GentlyLock {
    public static void main(String[] args) throws InterruptedException {
        Thread.sleep(5000);
        final GentlyLock gentlyLock = new GentlyLock();

        synchronized (gentlyLock){
            System.out.println("偏向锁"+ClassLayout.parseInstance(gentlyLock).toPrintable());
        }
        new Thread(() -> {
            synchronized (gentlyLock){
                System.out.println("轻量级锁"+ClassLayout.parseInstance(gentlyLock).toPrintable());
            }
        }).start();
    }
}
